package com.jt.yygh.hospital.dict;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.jt.yygh.hospital.VO.DictEeVo;
import com.jt.yygh.hospital.dict.mapper.DictMapper;
import com.jt.yygh.hospital.entity.cmn.Dict;
import org.springframework.beans.BeanUtils;

/**
 * @author jiang tao
 * @date 2022/2/21
 * @description:
 **/
public class DictListener extends AnalysisEventListener<DictEeVo> {

    private DictMapper dictMapper;

    public DictListener(DictMapper dictMapper){
        this.dictMapper = dictMapper;
    }


    /**
     * 一行一行的读取
     * @param dictEeVo
     * @param analysisContext
     */
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEeVo,dict);
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
